package com.gxa.zhonglong.service.impl;

import com.gxa.zhonglong.common.ExceptionCode;
import com.gxa.zhonglong.exception.BusinessException;
import com.gxa.zhonglong.mapper.GoodsConditionMapper;
import com.gxa.zhonglong.pojo.GoodsCondition;
import com.gxa.zhonglong.service.GoodsConditionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 *
 * @author : 宸濯
 * Date: 2021/11/01 12:25
 * Description:
 * Version: V1.0
 */
@Service
public class GoodsConditionServiceImpl implements GoodsConditionService {

    @Autowired
    private GoodsConditionMapper goodsConditionMapper;

    @Override
    public List<Map<String, Object>> selectAll() {
        return goodsConditionMapper.selectAll();
    }

    @Override
    public void add(GoodsCondition goodsCondition) throws BusinessException {
        if (!goodsConditionMapper.add(goodsCondition)) {
            throw new BusinessException(ExceptionCode.ADD_DEFEATED);
        }
    }

    @Override
    public void update(GoodsCondition goodsCondition) throws BusinessException {
        if (!goodsConditionMapper.update(goodsCondition)) {
            throw new BusinessException(ExceptionCode.UPDATE_FALSE);
        }
    }

    @Override
    public void del(List<Long> ids) throws BusinessException {
        if (!goodsConditionMapper.del(ids)) {
            throw new BusinessException(ExceptionCode.DELETE_FALSE);
        }
    }
}
